#include "NetworkCommon.h"
#include <Windows.h>

bool sendData(SOCKET socket, const char *data, long long size)
{
	long long sendedSize = 0;
	while(sendedSize < size)
	{
		long long tmp = send(socket, data + sendedSize, size - sendedSize, 0);
		if(tmp == SOCKET_ERROR)
		{
			return false;
		}
		sendedSize += tmp;
	}
	return true;
}

bool receiveData(SOCKET socket, char* buffer, long long size)
{
	long long receivedSize = 0;
	while(receivedSize < size)
	{
		long long tmp = recv(socket, buffer + receivedSize, size - receivedSize, 0);
		if(tmp == SOCKET_ERROR)
			return false;
		else if(tmp == 0)
			return false;
		receivedSize += tmp;
	}
	return true;
}
